<?php

namespace AdminBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * TaskQueueWaiting
 *
 * @ORM\Table(name="task_queue_waiting")
 * @ORM\Entity(repositoryClass="AdminBundle\Repository\TaskQueueWaitingRepository")
 */
class TaskQueueWaiting
{
    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=45, nullable=false)
     */
    private $name = '';

    /**
     * @var string
     *
     * @ORM\Column(name="note", type="string", length=45, nullable=false)
     */
    private $note = '';

    /**
     * @var string
     *
     * @ORM\Column(name="creator", type="string", length=45, nullable=false)
     */
    private $creator = '';

    /**
     * @var string
     *
     * @ORM\Column(name="ip", type="string", length=20, nullable=false)
     */
    private $ip = '';

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="ctime", type="datetime", nullable=false)
     */
    private $ctime = 'CURRENT_TIMESTAMP';

    /**
     * @var string
     *
     * @ORM\Column(name="uri", type="string", length=45, nullable=false)
     */
    private $uri = '';

    /**
     * @var string
     *
     * @ORM\Column(name="method", type="string", length=20, nullable=false)
     */
    private $method = '';

    /**
     * @var string
     *
     * @ORM\Column(name="action", type="string", length=20, nullable=false)
     */
    private $action = '';

    /**
     * @var string
     *
     * @ORM\Column(name="params", type="text", length=65535, nullable=false)
     */
    private $params = '';

    /**
     * @var string
     *
     * @ORM\Column(name="device_name", type="string", length=45, nullable=false)
     */
    private $deviceName = '';

    /**
     * @var integer
     *
     * @ORM\Column(name="device_id", type="integer", nullable=false)
     */
    private $deviceId = '0';

    /**
     * @var integer
     *
     * @ORM\Column(name="template_id", type="integer", nullable=false)
     */
    private $templateId = '0';

    /**
     * @var integer
     *
     * @ORM\Column(name="device_group_id", type="integer", nullable=false)
     */
    private $deviceGroupId = '0';

    /**
     * @var string
     *
     * @ORM\Column(name="webchat_username", type="string", length=45, nullable=false)
     */
    private $webchatUsername = '';

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;


    /**
     * Set name
     *
     * @param string $name
     *
     * @return TaskQueueWaiting
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set note
     *
     * @param string $note
     *
     * @return TaskQueueWaiting
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

    /**
     * Get note
     *
     * @return string
     */
    public function getNote()
    {
        return $this->note;
    }

    /**
     * Set creator
     *
     * @param string $creator
     *
     * @return TaskQueueWaiting
     */
    public function setCreator($creator)
    {
        $this->creator = $creator;

        return $this;
    }

    /**
     * Get creator
     *
     * @return string
     */
    public function getCreator()
    {
        return $this->creator;
    }

    /**
     * Set ip
     *
     * @param string $ip
     *
     * @return TaskQueueWaiting
     */
    public function setIp($ip)
    {
        $this->ip = $ip;

        return $this;
    }

    /**
     * Get ip
     *
     * @return string
     */
    public function getIp()
    {
        return $this->ip;
    }

    /**
     * Set ctime
     *
     * @param \DateTime $ctime
     *
     * @return TaskQueueWaiting
     */
    public function setCtime($ctime)
    {
        $this->ctime = $ctime;

        return $this;
    }

    /**
     * Get ctime
     *
     * @return \DateTime
     */
    public function getCtime()
    {
        return $this->ctime;
    }

    /**
     * Set uri
     *
     * @param string $uri
     *
     * @return TaskQueueWaiting
     */
    public function setUri($uri)
    {
        $this->uri = $uri;

        return $this;
    }

    /**
     * Get uri
     *
     * @return string
     */
    public function getUri()
    {
        return $this->uri;
    }

    /**
     * Set method
     *
     * @param string $method
     *
     * @return TaskQueueWaiting
     */
    public function setMethod($method)
    {
        $this->method = $method;

        return $this;
    }

    /**
     * Get method
     *
     * @return string
     */
    public function getMethod()
    {
        return $this->method;
    }

    /**
     * Set action
     *
     * @param string $action
     *
     * @return TaskQueueWaiting
     */
    public function setAction($action)
    {
        $this->action = $action;

        return $this;
    }

    /**
     * Get action
     *
     * @return string
     */
    public function getAction()
    {
        return $this->action;
    }

    /**
     * Set params
     *
     * @param string $params
     *
     * @return TaskQueueWaiting
     */
    public function setParams($params)
    {
        $this->params = $params;

        return $this;
    }

    /**
     * Get params
     *
     * @return string
     */
    public function getParams()
    {
        return $this->params;
    }

    /**
     * Set deviceName
     *
     * @param string deviceName
     *
     * @return TaskQueueWaiting
     */
    public function setDeviceName($deviceName)
    {
        $this->deviceName = $deviceName;

        return $this;
    }

    /**
     * Get deviceName
     *
     * @return string
     */
    public function getDeviceName()
    {
        return $this->deviceName;
    }

    /**
     * Set deviceId
     *
     * @param integer $deviceId
     *
     * @return TaskQueueWaiting
     */
    public function setDeviceId($deviceId)
    {
        $this->deviceId = $deviceId;

        return $this;
    }

    /**
     * Get deviceId
     *
     * @return integer
     */
    public function getDeviceId()
    {
        return $this->deviceId;
    }

    /**
     * Set templateId
     *
     * @param integer $templateId
     *
     * @return TaskQueueWaiting
     */
    public function setTemplateId($templateId)
    {
        $this->templateId = $templateId;

        return $this;
    }

    /**
     * Get deviceGroupId
     *
     * @return integer
     */
    public function getTemplateId()
    {
        return $this->templateId;
    }

    /**
     * Set deviceGroupId
     *
     * @param integer $deviceGroupId
     *
     * @return TaskQueueWaiting
     */
    public function setDeviceGroupId($deviceGroupId)
    {
        $this->deviceGroupId = $deviceGroupId;

        return $this;
    }

    /**
     * Get deviceGroupId
     *
     * @return integer
     */
    public function getDeviceGroupId()
    {
        return $this->deviceGroupId;
    }

    /**
     * Set webchatUsername
     *
     * @param string $webchatUsername
     *
     * @return TaskQueueWaiting
     */
    public function setWebchatUsername($webchatUsername)
    {
        $this->webchatUsername = $webchatUsername;

        return $this;
    }

    /**
     * Get webchatUsername
     *
     * @return string
     */
    public function getWebchatUsername()
    {
        return $this->webchatUsername;
    }

    public function toTask($jsonEncode = true)
    {
        $params = json_decode($this->getParams());
        $task = ['id' => $this->getId(), 'name' => $this->getName(),
            'uri' => $this->getUri(), 'method' => $this->getMethod(),
            'action' => $this->getAction(), 'params' => $params
        ];
        return $jsonEncode ? json_encode($task) : $task;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }
}
